export const myMixin = {
    data() {
        return {
            headers: {
                Authorization:
                  this.$const.TOKEN_PREFIX + this.getCookie(this.$const.tokenKey)
              }
        }
    },
    methods: {
        loginOut: function () {
            this.clearAllCookie();
            sessionStorage.clear();
            localStorage.clear();
            this.$store.commit("loginOut");
            this.$router.push("/home");
        },
        verifyAccess: function (code) {
            if (code == 403) {
                this.loginOut();
                return false;
            }
            return true;
        },
        beforeAvatarUpload(file) {
            const isJPG = file.type === "image/jpeg";
            const isLt2M = file.size / 1024 / 1024 < 2;

            if (!isJPG) {
                this.$message.error("上传头像图片只能是 JPG 格式!");
            }
            if (!isLt2M) {
                this.$message.error("上传头像图片大小不能超过 2MB!");
            }
            return isJPG && isLt2M;
        }
    }
}